from django.shortcuts import render, render_to_response

# Create your views here.
from app03 import forms
def index(request):
    ret={'data':None, 'error':''}
    obj=forms.ALogin()
    print obj
    ret['data']=obj
    if request.method=='POST':
        checkForm=forms.ALogin(request.POST)
        print checkForm
        checkResult = checkForm.is_valid()
        if checkResult:
            pass
        else:
            errors = checkForm.errors
            #ret['error']=errors
            #django.forms.utils.ErrorDict
            print errors
            firstErrorMsg=checkForm.errors.as_data().values()[0][0].messages[0]
            ret['error']=firstErrorMsg
            ret['data']=checkForm
            print firstErrorMsg
            print type(errors)
    return render_to_response('app03/index.html',ret)